package models

import (
	// "fmt"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
	"time"
)

type Company struct {
	Id           int       `orm:"column(Id);auto"`
	Name         string    `orm:"column(name);null"`
	ShortName    string    `orm:"column(shortName);null"`
	Tag          string    `orm:"column(tag);null"`
	Logo         string    `orm:"column(logo);null"`
	Address      string    `orm:"column(address);null"`
	Description  string    `orm:"column(description);size(4000);null"`
	Province     string    `orm:"column(province);size(11);null"`
	City         string    `orm:"column(city);size(11);null"`
	FinanceState int       `orm:"column(financeState);type(int);size(11);null"`
	WebsitUrl    string    `orm:"column(websitUrl);size(250);null"`
	Weibo        string    `orm:"column(weibo);size(250);null"`
	AndroidUrl   string    `orm:"column(androidUrl);size(250);null"`
	Wechat       string    `orm:"column(wechat);size(50);null"`
	ImgArray     string    `orm:"column(imgArray);size(255);null"`
	Label        string    `orm:"column(label);size(255);null"`
	Mfrate       int       `orm:"column(mfrate);type(int);size(11);null"`
	IosUrl       string    `orm:"column(iosUrl);size(255);null"`
	CompanySize  int       `orm:"column(companySize);type(int);size(11);null"`
	CreateByUid  int       `orm:"column(CreateByUid);null"`
	CreateDate   time.Time `orm:"column(CreateDate);auto_now_add;type(datetime);null"`
	UpdateDate   time.Time `orm:"column(UpdateDate);auto_now;type(datetime);null"`
	Status       int       `orm:"column(Status);null"`
}

// map[address:[新源南路200号] province:[北京] financeState:[1] websitUrl:[] weibo:[] headImage:[1]
// androidUrl:[] dosubmit:[true] wechat:[] imgArray:[htt
// p://www.zhaopins.com/COMPANY_PIC/16/1296_1437240486309.jpg]
// description:[炎柴网络]
// id:[1296]
// name:[炎柴网络]
// shortName:[炎柴网络]
// tag:[互联网]
// city:[朝阳区]
// label:[弹性工作]
// mfrate:[5]
// iosUrl:[]
// companySize:[1]
// ]

func init() {
	orm.RegisterModel(new(Company))
}

func (t *Company) TableName() string {
	return "057dg_company"
}

func AddCompany(c *Company) (id int64, err error) {
	orm := orm.NewOrm()
	id, err = orm.Insert(c)
	return
}

// func UpdateCompany(interface{}) (num int64, err error) {
// 	o := orm.NewOrm()
// 	num, err = o.Update(R)
// 	if err == nil {
// 		return num, nil
// 	}
// 	return num, err
// }

// func FindOneCompany(id int) (company *Company, err error) {
// 	o := orm.NewOrm()
// 	company = &Company{CreateByUid: id}
// 	if err := o.Read(company, "CreateByUid"); err == nil {
// 		return company, nil
// 	}
// 	return nil, err
// }
